class Solution:
	# @param num, a list of integer
	# @return a list of lists of integers
	def permute(self, num):
		if len(num) < 2:
			return [num]
		ans = []
		self.__permute(ans,len(num),num)
		return ans

	def __permute(self, ans, end, num):
		if end == 1:
			ans.append(num[:])
			return
		for i in xrange(end):
			self.__swap(num, i, end-1)
			self.__permute(ans, end-1, num)
			self.__swap(num, i, end-1)

	def __swap(self, num, i, j):
		t = num[i]
		num[i] = num[j]
		num[j] = t

if __name__ == '__main__':
	so = Solution()
	a = [3,4]
	print so.permute(a)
